//
//  MineHeaderView.m
//  Cycling
//
//  Created by chijianguo on 2023/3/12.
//

#import "MineHeaderView.h"

@implementation MineHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    UIImageView *bgview = [[UIImageView alloc] init];
    bgview.image = [UIImage imageNamed:@"icon_mine_headbg"];
    [self addSubview:bgview];
    [bgview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self).offset(0);
    }];
    
    self.currentCarLB = [[UILabel alloc] init];
    self.currentCarLB.font = FONT_PRIMARY_TITLE;
    self.currentCarLB.textColor = COLOR_WHITE;
    self.currentCarLB.text = @"自行车1";
    [self addSubview:self.currentCarLB];
    [self.currentCarLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(MARGIN_MAX);
        make.top.equalTo(self).offset(SafeAreaTopHeight+MARGIN_MIN);
        make.height.mas_equalTo(30);
    }];
    UIImageView *downimview = [[UIImageView alloc] init];
    downimview.image = [UIImage imageNamed:@"icon_mine_down"];
    [self addSubview:downimview];
    [downimview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.currentCarLB.mas_right).offset(MARGIN_MIDDLE);
        make.size.mas_equalTo(CGSizeMake(13, 8));
        make.centerY.mas_equalTo(self.currentCarLB.mas_centerY);
    }];
    self.downimview = downimview;

    self.carSelectBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self addSubview:self.carSelectBtn];
    [self.carSelectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(MARGIN_MAX);
        make.right.equalTo(downimview.mas_right).offset(0);
        make.top.equalTo(self).offset(SafeAreaTopHeight+MARGIN_MIN);
        make.height.mas_equalTo(30);

    }];
    
    self.carSettingBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.carSettingBtn setTitle:@"  设置" forState:(UIControlStateNormal)];
    [self.carSettingBtn setImage:[UIImage imageNamed:@"icon_mine_setting"] forState:(UIControlStateNormal)];
    [self.carSettingBtn setupEdgeInsetsByDirection:(DFButtonImageDirectionLeft)];
    [self addSubview:self.carSettingBtn];
    [self.carSettingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-MARGIN_MAX);
        make.top.equalTo(self).offset(SafeAreaTopHeight+MARGIN_MIN);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(90);
    }];

    self.headerImageView = [[UIImageView alloc] init];
    self.headerImageView.layer.cornerRadius = 43;
    self.headerImageView.layer.masksToBounds = YES;
    [self addSubview:self.headerImageView];
    [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(MARGIN_MAX);
        make.top.equalTo(self.carSelectBtn.mas_bottom).offset(MARGIN_MAX);
        make.height.mas_equalTo(86);
        make.width.mas_equalTo(86);
    }];
    self.headPhotoBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self addSubview:self.headPhotoBtn];
    [self.headPhotoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(MARGIN_MAX);
        make.top.equalTo(self.carSelectBtn.mas_bottom).offset(MARGIN_MAX);
        make.height.mas_equalTo(86);
        make.width.mas_equalTo(86);
    }];
        
    self.nameLB = [[UILabel alloc] init];
    self.nameLB.font = FONT_PRIMARY_TITLE;
    self.nameLB.textColor = COLOR_WHITE;
    [self addSubview:self.nameLB];
    [self.nameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headPhotoBtn.mas_right).offset(MARGIN_MIDDLE);
        make.top.equalTo(self.headPhotoBtn.mas_top).offset(MARGIN_MIDDLE);
        make.size.mas_equalTo(CGSizeMake(200, 30));
    }];
    
    self.numLB = [[UILabel alloc] init];
    self.numLB.font = FONT_SECONDARY_TITLE;
    self.numLB.textColor = COLOR_WHITE;
    [self addSubview:self.numLB];
    [self.numLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headPhotoBtn.mas_right).offset(MARGIN_MIDDLE);
        make.bottom.equalTo(self.headPhotoBtn.mas_bottom).offset(-MARGIN_MIDDLE);
        make.height.mas_equalTo(30);
    }];


    self.carEidtBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.carEidtBtn setImage:[UIImage imageNamed:@"icon_mine_eidt"] forState:(UIControlStateNormal)];
    [self addSubview:self.carEidtBtn];
    [self.carEidtBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-MARGIN_MAX-MARGIN_MIDDLE);
        make.centerY.mas_equalTo(self.nameLB.mas_centerY);
        make.height.mas_equalTo(25);
        make.width.mas_equalTo(25);
    }];

    self.carRecommentIMV = [[UIImageView alloc] init];
    self.carRecommentIMV.image = [UIImage imageNamed:@"icon_mine_medal"];
    [self addSubview:self.carRecommentIMV];
    [self.carRecommentIMV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(MARGIN_MAX);
        make.top.equalTo(self.headPhotoBtn.mas_bottom).offset(MARGIN_MIDDLE);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(30);
    }];

    self.carRecommentLB = [[UILabel alloc] init];
    self.carRecommentLB.font = FONT_SECONDARY_TITLE;
    self.carRecommentLB.textColor = COLOR_WHITE;
    [self addSubview:self.carRecommentLB];
    [self.carRecommentLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.carRecommentIMV.mas_right).offset(0);
        make.top.equalTo(self.headPhotoBtn.mas_bottom).offset(MARGIN_MIDDLE);
        make.height.mas_equalTo(30);
    }];

    self.carRecommentBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self addSubview:self.carRecommentBtn];
    [self.carRecommentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(MARGIN_MAX);
        make.top.equalTo(self.headPhotoBtn.mas_bottom).offset(MARGIN_MIDDLE);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(130);
    }];

}

@end
